home *** CD-ROM | disk | FTP | other *** search
/ Aminet 13 / Aminet 13 - August 1996.iso / Aminet / comm / fido / MM_AntiBomb010.lha / MM / Rexx / MM_AntiBomb.rexx.cmp < prev   
Text File  |  1996-05-04  |  7KB  |  18 lines

  1. /*
  2.  
  3.                         $VER: MM_AntiBomb  0.10/c  (02-05-96)
  4.  
  5.                             (C) 1996 Kent B. Hansen
  6.  
  7. */
  8.  
  9. /* Compressed with CompressRexx v2.1, (C) 1993-96 Robert Hofmann */
  10. options cache;options failat 99;options results;signal on break_c;signal on break_d;signal on break_e;signal on break_f;signal on halt;signal on ioerr;signal on syntax;address 'MAILMANAGER';Main:;call Init;call Header;call Read_Cfg;call Check_File(system.listcmd);call CheckInbound;call Quit(0, 'All done.');exit;break_c:; break_d:; break_e:; break_f:; halt:;signal off break_c;signal off break_d;signal off break_e;signal off break_f;signal off halt;return_code = 5;error_line = 0;error_msg = 'Execution halted!!!';rc = 0;signal Exit;Exit:;select;when return_code>=40 then error = 'INTERNAL-ERROR:';when return_code>=30 then error = 'IO-ERROR:';when return_code>=20 then error = 'ERROR:';when return_code>=10 then error = 'WARNING:';when return_code>=5 then error = 'INFO:';otherwise error = '';end;call Log();call Log('***' strip(error error_msg) '***', '+');call Log(,'\');call setclip('MM_LogPre', system.mm.logpre);exit return_code;Get_Version: procedure;parse arg mode;parse value sourceline(3-mode) with . . ver .
  11. parse var ver tst 'ß' .;if ~datatype(strip(tst, 'b', '/c '), 'N') then if ~mode then ver = Get_Version(1);else exit 99;return ver;Header:;call Log(,'/');call Log('***' system.prg.id '***', '+');call Log(' 'system.prg.cr);call Log();return;Init:;system. = 0;system.prg.ver = Get_Version(0);system.prg.name = 'MM_AntiBomb';system.prg.id = system.prg.name 'v'system.prg.ver;system.prg.cfg = 'MM:Config/'system.prg.name'.cfg';system.prg.cr = '(C) 1996 Kent B. Hansen';system.tmpfile = 'T:'system.prg.name'.tmp';system.mm.logpre = getclip('MM_LogPre');system.prg.logpre = system.mm.logpre'|';call setclip('MM_LogPre', system.prg.logpre);MM_GetCfgPaths 'system.mm';system.maxratio = 85;system.listcmd = 'c:list';call Include_Lib('rexxsupport');return;Include_Lib: procedure Expose system.;parse arg lib, prio;if right(upper(lib), 8)~='.LIBRARY' then lib = lib'.library';if prio='' then prio = 0;if ~show('l', lib) then if ~addlib(lib, prio, -30, 0) then call Quit(20, 'Could not open' lib'!!!');return
  12. Check_File: procedure expose system.;parse arg filename;if ~exists(filename) then call Quit(10,'Could not find' filename'!!! ***');return;IOerr:;signal off ioerr;return_code = 20;error_line = sigl;error_msg = 'IO-error' rc 'at line' sigl '['errortext(rc)']');rc = 0;signal Exit;Log: procedure Expose system.;parse arg text, pre, level;if ~datatype(level, 'N') then level = system.prg.loglevel;tmp = word('PRG MM', (pre~='')+1);text = system.tmp.logpre || pre' 'text;MM_WriteLog 'text' level;return;Quit:;parse arg return_code, error_msg;error_line = 0;rc = 0;signal Exit;Read_Cfg: procedure Expose system.;MM_ReadStem system.prg.cfg 'cfg';if RC~=0 then call Quit(31, 'Unable to read' system.prg.cfg'!!!');call Log('Reading config...');do l=0 to cfg.count-1;parse value strip(translate(cfg.l, ' ', '9'x)) with key args ';' .;key = upper(strip(key));args = strip(args);select;when key='' then iterate;when key='#PACKER' then do;system.packer.count = system.packer.count + 1;number = system.packer.count
  13. call CheckArgsOK(l+1,args);system.packer.number.name = word(args,1);system.packer.number.idpos = word(args,2);system.packer.number.id = word(args,3);system.packer.number.tpos = subword(args,4,2);system.packer.number.cmd = subword(args,6);end;when key='#RATIO' then system.maxratio = CheckRatio(args);when key='#LIST' then system.listcmd = args;when key='#DEBUG' then system.prg.debug = 1;otherwise say '*** CFG-ERROR: Unknown keword "'key'" at line' l+1'!!!';end;end;return;CheckArgsOK: procedure expose system.;parse arg line, opts;if words(opts)<6 then call Quit(20,'Too few archiver options at line' line'!!!');call CheckNumber(word(opts,2));call CheckNumber(word(opts,4));call CheckNumber(word(opts,5));if word(opts,2)<1 | word(opts,2)>5 then call Quit(20,'Illegal ID-position at line' line'!!!');if length(word(opts,3))+word(opts,2)>6 then call Quit(20,'ArchiverID exceeds fifth character at line' line'!!!');if word(opts,4)<1 | word(opts,5)<1 then call Quit(20,'Illegal position at line' line'!!!')
  14. if ~exists(word(opts,6)) then call Quit(20,'Could not find archiver' word(opts,6)' specified at line' line'!!!');return;CheckNumber: procedure expose line system.;parse arg number;if ~datatype(number,'n') then call Quit(20,'Illegal archiver options at line' line'. "'number'" is not a number!!!');return;CheckRatio: procedure expose system.;parse arg ratio '.';if ratio<0 | ratio>100 then call Quit(20,'Illegal ratiovalue.' ratio 'not between 0 and 100!!!');return ratio;Syntax:;signal off syntax;return_code = 40;error_line = sigl;error_msg = 'Syntax-error' rc 'at line' sigl '['errortext(rc)']';rc = 0;signal Exit;Command: procedure expose system.;parse arg cmd, log;if log='' then log=5;address command cmd;if rc>log then call Log('*** ERROR: Command "'cmd'" returned' rc'.');return rc;GetID: procedure expose system.;parse arg filename;if ~open('file',filename,'r') then call Quit(30,'Unable to read' filename'!!!');id = '';do i=1 to 5;id = id''readch('file');end
  15. if ~close('file') then call Quit(30,'Unable to close' filename'!!!');return id;MatchID: procedure;parse arg fileid, idpos, id;return substr(fileid,idpos,length(id)) = id;GetSize: procedure expose system.;parse arg archive;archiveid = GetID(archive);do i=1 to system.packer.count;if MatchID(archiveid,system.packer.i.idpos,system.packer.i.id) then do;call Command(system.packer.i.cmd' 'archive' >'system.tmpfile);MM_ReadStem system.tmpfile 'listing';if RC~=0 then call Quit(30,'Unable to read' system.tmpfile'!!!');MM_DeleteFile system.tmpfile;if RC~=0 then call Quit(30,'Unable to delete' system.tmpfile'!!!');position = listing.count - word(system.packer.i.tpos,1);return word(listing.position, word(system.packer.i.tpos,2));end;end;return -1;GetRatio: procedure expose system.;parse arg filename size .;expanded = GetSize(filename);if expanded = -1 then return 0;return trunc(100*(expanded-size)/expanded,2);CheckInbound: procedure expose system.
  16. wildcard='(????????|#[0-9].#[0-9].#[0-9].#[0-9]).(MO|TU|WE|TH|FR|SA|SU)([0-9]|[A-F])';call Command(system.listcmd system.mm.inbound''wildcard' files lformat="%F%N %L %N" to' system.tmpfile);MM_ReadStem system.tmpfile 'archives';if RC~=0 then call Quit(30,'Unable to read' system.tmpfile'!!!');MM_DeleteFile system.tmpfile;if RC~=0 then call Quit(30,'Unable to delete' files.t'!!!');do i=0 to archives.count - 1;ratio= GetRatio(archives.i);if ratio > system.maxratio then do;call Log(word(archives.i,3)' packed too hard ('ratio'%). Moved to bad!!');MM_MoveFile word(archives.i,1) system.mm.baddir'BOMB_'word(archives.i,3);if RC~=0 then call Quit(30,'Unable to move' words(archives.i,3)' to bad!!!');end;else call DebugLog(word(archives.i,3) 'OK. ('ratio'%)');end;return;DebugLog: procedure expose system.;parse arg logline;if system.prg.debug then call Log(logline);return
  17. /* Original script: 378 lines, 7435 bytes */
  18.